<?php 
class Helper_Core_Form_Items
{
    public function __construct()
    {
        $test = '';
    }

    public function getFormItems($modelItems,$form,$sufixName=null)
    {
        $result = array();

        foreach ($modelItems as $_model) {
            $data = array();

            $data['type'] = $_model->getInputType();
            $data['name'] = is_null($sufixName)?$_model->getCode():$sufixName.'['.$_model->getCode().']';
            $data['value'] = $form->getData($_model->getCode());
            $data['title']= $_model->getName();
            $data['label']= $_model->getName();
            $data['required'] = $_model->getRequired();

            $sourceModel = $_model->getSourceModel();
            if(($_model->getInputType() == 'multiselect' || $_model->getInputType() == 'select')
                && !empty($sourceModel)) {
                $sourceModel = new $sourceModel();
                $data['params'] = $sourceModel->getOptionArray();
            }

            $data['comment']=$_model->getComment();
            $result[] = $data;
        }
        return $result;
    }
}